﻿#pragma once

_NAMESPACE_BEGIN


typedef std::basic_string<TCHAR> tstring;
typedef std::basic_stringstream<TCHAR> tstringstream;

#define SAFEDELETE(x) if(x){delete x;x=NULL;}
#define SAFEDELETEARRAY(x) if(x){delete[]x;x=NULL;}
#define SAFERELEASE(x) 		if(x) { (x)->Release();x = NULL; }
#define CONST_REF(x) const x& 

/// 申请一个基本类型的内存
#define newmem(a,b) a=new b;

/// 申请一个对象的内存
#define newobj(a,b) a=new b();

/// 申请一个有参数对象的内存
#define newobj1(a,b,c) a=new b(c);

/// 申请一个数组的内存
#define newarray(a,b,s) a=new b[s];

/// 释放一段内存
#define delmem(a) SAFEDELETE(a);

/// 释放一个数组的内存
#define delarray(a) SAFEDELETEARRAY(a);

/// 不大于等于
#define DONT_MORE_E(x,y)	\
	if((x)>=(y))\
	(x)=(y);

/// 不小于等于
#define DONT_LESS_E(x,y)	\
	if((x)<=(y))\
	(x)=(y);

/// 不大于
#define DONT_MORE(x,y)	\
	if((x)>(y))\
	(x)=(y);

/// 不小于
#define DONT_LESS(x,y)	\
	if((x)<(y))\
	(x)=(y);

/// 向上去整
inline int GosUp(int x,int y)
{
	if(x%y == 0)
		return x/y;
	else
		return x/y + 1;
}

/// NOP
#define DO_NOTHING


_NAMESPACE_END

